package com.yuan.springcloud.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 服务公共异常父类
 * @author YouYuan
 * @date 2020/8/18 22:01
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ServiceException extends RuntimeException {

    protected String code;

    protected Object data;

    public ServiceException(String message) {
        super(message);
    }

    public ServiceException() {
        super();
    }

    public ServiceException(String message, String code) {
        super(message);
        this.code = code;
    }

    public ServiceException(String message, String code, Object data) {
        super(message);
        this.code = code;
        this.data = data;
    }

    public ServiceException(ErrorEnum errorEnum) {
        super(errorEnum.getMessage());
        this.code = errorEnum.getErrCode();
    }

    public ServiceException(ErrorEnum errorEnum, Object data) {
        super(errorEnum.getMessage());
        this.code = errorEnum.getErrCode();
        this.data = data;
    }

}
